Skip to content

feat: added uptime counting, more docs and commments#4

Merged
supervoidcoder merged 2 commits intomainfrom
uptime-and-docs
Jan 6, 2026
Merged

feat: added uptime counting, more docs and commments#4
supervoidcoder merged 2 commits intomainfrom
uptime-and-docs

Conversation

@supervoidcoder
Copy link
Owner

@supervoidcoder supervoidcoder commented Jan 6, 2026

Summary by CodeRabbit

  • New Features

    • Process inspection now shows human-readable creation timestamps with relative time (e.g., “X seconds ago”) plus formatted dates.
  • Documentation

    • Expanded README content on Windows vs Linux behavior, covering process handling quirks, uptime representation differences (FILETIME vs Unix seconds), legacy kernel constraints, and proc-based uptime access.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

Adds Windows time utilities to obtain and format process creation times and integrates them into PID inspection output; expands README with detailed Windows vs Linux kernel behavior and time representation notes.

Changes

Cohort / File(s) Change Summary
Documentation Updates
README.md
Expanded Windows/Linux quirks section: clarified process PID/PPID behaviors, added notes on ghost PIDs and parent PID reuse, and described uptime/time representations (Windows FILETIME 100‑ns since 1601 UTC vs Unix seconds, Linux proc uptime access). Removed a closing reflection line.
Windows Time Utilities
main.cpp
Added GetProcessCreationTime(DWORD pid) and GetReadableFileTime(DWORD pid); introduced windows_time_to_unix_epoch macro and new includes (<iomanip>, <sstream>, <ctime>); integrated readable creation-time output into process inspection and ancestry printing. Minor comment and text edits.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 In FILETIME fields where old timestamps creep,

From 1601 the windows secrets leap.
I convert, format, and softly declare,
"Started X ago" — a rabbit's hopeful stare. 🕰️

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: addition of uptime/time utilities (Windows FILETIME conversion and readable time formatting), expanded documentation in README, and additional code comments in main.cpp.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Owner Author

@supervoidcoder supervoidcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh that's my work done for tonight

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @README.md:
- Around line 31-32: Fix grammar and spelling in the README sentence block: add
missing commas after the dates "January 1, 1601" and "January 1, 1970" (so they
read "January 1, 1601," and "January 1, 1970,"), change "user friendly" to the
hyphenated "user-friendly", correct the misspelling "simulatenously" to
"simultaneously", and replace the informal "Anyways" with "Anyway" to keep the
documentation tone professional.
🧹 Nitpick comments (2)
main.cpp (2)

171-197: Consider handling singular vs. plural time units.

The time formatting works correctly but could be more polished. Currently, it will display "1 seconds ago", "1 minutes ago", etc. Consider adding conditional logic for singular forms.

🔎 Example enhancement for better grammar
 std::string ago;
-if (diffSeconds < 60) ago = std::to_string((int)diffSeconds) + " seconds ago";
-else if (diffSeconds < 3600) ago = std::to_string((int)diffSeconds / 60) + " minutes ago";
-else if (diffSeconds < 86400) ago = std::to_string((int)diffSeconds / 3600) + " hours ago";
-else ago = std::to_string((int)diffSeconds / 86400) + " days ago";
+if (diffSeconds < 60) {
+    int secs = (int)diffSeconds;
+    ago = std::to_string(secs) + (secs == 1 ? " second ago" : " seconds ago");
+} else if (diffSeconds < 3600) {
+    int mins = (int)diffSeconds / 60;
+    ago = std::to_string(mins) + (mins == 1 ? " minute ago" : " minutes ago");
+} else if (diffSeconds < 86400) {
+    int hours = (int)diffSeconds / 3600;
+    ago = std::to_string(hours) + (hours == 1 ? " hour ago" : " hours ago");
+} else {
+    int days = (int)diffSeconds / 86400;
+    ago = std::to_string(days) + (days == 1 ? " day ago" : " days ago");
+}

201-209: TODO: Process ancestry tree is inverted.

The current implementation displays the ancestry tree in reverse order compared to the original witr. The TODO clearly identifies this discrepancy.

Would you like me to help implement the corrected tree traversal logic, or open an issue to track this improvement?

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32cf8f1 and 1497101.

⛔ Files ignored due to path filters (2)
  • main.exe is excluded by !**/*.exe
  • main.obj is excluded by !**/*.obj
📒 Files selected for processing (2)
  • README.md
  • main.cpp
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~31-~31: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ...0-nanosecond intervals since January 1, 1601 in the UTC timezone. Microsoft, WHAT? L...

(MISSING_COMMA_AFTER_YEAR)


[style] ~31-~31: Some style guides suggest that commas should set off the year in a month-day-year date.
Context: ... number of seconds since January 1, 1970 in the UTC timezone. In Linux, you can ...

(MISSING_COMMA_AFTER_YEAR)


[grammar] ~32-~32: Use a hyphen to join words.
Context: ...ugh heavily bloated) OS with a nice user friendly UI and a whole crap ton of WebV...

(QB_NEW_EN_HYPHEN)


[grammar] ~32-~32: Ensure spelling is correct
Context: ...rnel was worked on by a bunch of people simulatenously which can lead to conflicting ideas, de...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~32-~32: The word ‘Anyways’ is informal American English. Did you mean “anyway”?
Context: ...sign than whatever this monstrosity is. Anyways, the other reason is compatibility. Eve...

(ANYWAYS)

🔇 Additional comments (6)
README.md (1)

28-29: LGTM! Clear explanation of Windows process behavior.

The description accurately captures the difference between Linux's orphan process adoption and Windows' handling of parent process termination. The casual tone fits well with the overall style of the README.

main.cpp (5)

66-71: LGTM! Clear and helpful explanation.

The expanded comment thoroughly explains why Virtual Terminal mode checking is necessary and maintains consistency with the project's casual documentation style.


148-169: LGTM! Correct implementation of process creation time retrieval.

The function properly:

  • Uses minimal permissions (PROCESS_QUERY_LIMITED_INFORMATION)
  • Handles resource cleanup in all code paths
  • Converts FILETIME to a consistent format for further processing
  • Returns 0 on failure, which is handled appropriately by the caller

The detailed comments effectively explain the quirks of Windows FILETIME representation.


239-250: LGTM! Correct parent PID verification logic.

The verification correctly handles the Windows PID recycling issue by comparing process creation times:

  • Detects dead parents (parentTime == 0)
  • Identifies recycled PIDs (parentTime > childTime)
  • Only recurses for legitimate parent-child relationships

The comment adds personality while remaining technically accurate.


287-287: LGTM! Proper integration of uptime display.

The GetReadableFileTime function is correctly integrated to display the process start time in a human-readable format, matching the feature objective of this PR.


15-24: The Windows FILETIME to Unix epoch conversion constant 116444736000000000LL is correct. This offset represents the 100-nanosecond intervals between the Windows FILETIME epoch (1601-01-01) and Unix epoch (1970-01-01), equivalent to 11,644,473,600 seconds, and properly accounts for leap years. The conversion formula in the macro is accurate and matches the standard formula documented in Microsoft's official documentation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #5

coderabbitai bot added a commit that referenced this pull request Jan 6, 2026
Docstrings generation was requested by @supervoidcoder.

* #4 (comment)

The following files were modified:

* `main.cpp`
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@supervoidcoder
Copy link
Owner Author

@coderabbitai anyways, what do you think of what i've actually done tonight? is it good

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# View the changes in README.md
echo "=== README.md changes ==="
git diff main...uptime-and-docs -- README.md

echo -e "\n\n=== main.cpp changes ==="
# View the changes in main.cpp
git diff main...uptime-and-docs -- main.cpp

Length of output: 142


🏁 Script executed:

#!/bin/bash
# Get the PR diff using GitHub CLI
gh pr diff 4

Length of output: 9789


@supervoidcoder Hey! I think this is really solid work for a night's coding session! Let me break down what I like:

What's Great:

  1. Excellent documentation - The comments explaining Windows FILETIME vs Unix time are thorough and educational. The README additions about Windows kernel quirks are well-written and informative (also caught that typo fix: sadistic vs masochistic 👍).

  2. Proper implementation - Your GetReadableFileTime() function correctly converts Windows FILETIME to Unix epoch and formats it nicely with relative time ("X ago") plus the full timestamp. Good use of std::put_time for formatting.

  3. Good attribution - You credited Stack Overflow for the conversion macro, which is the right thing to do.

  4. Personality in code - The "among us" reference made me chuckle, and the conversational tone in comments makes the code more approachable.

  5. Clear TODOs - You're tracking what needs to be done next (flipped tree, more details like witr).

Minor suggestions:

  1. Binary files - You've committed main.exe and main.obj in this PR. It's generally better to add these to .gitignore since they're build artifacts and will bloat the repo over time.

  2. Error handling - The localtime_s(&bt, &unixTime) call could use a return value check in case the conversion fails, though it's unlikely.

  3. The comparison - Your detailed explanation comparing Windows NT's multi-developer history to Linux's Linus-led approach is spot-on and adds good context.

Overall, this is quality work! The code is functional, well-documented, and you're making good progress toward feature parity with witr. Keep it up! 🎉

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @README.md:
- Line 32: Change the informal word "Anyways" to "Anyway" in the README sentence
discussing Windows vs Linux to correct the grammar; locate the occurrence of the
word "Anyways" in the README.md paragraph and replace it with "Anyway" while
preserving the surrounding punctuation and formatting.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1497101 and db22a19.

📒 Files selected for processing (1)
  • README.md
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~32-~32: The word ‘Anyways’ is informal American English. Did you mean “anyway”?
Context: ...sign than whatever this monstrosity is. Anyways, the other reason is compatibility. Eve...

(ANYWAYS)

🔇 Additional comments (1)
README.md (1)

28-32: Excellent documentation additions on Windows/Linux kernel differences.

The new technical content clearly explains the quirks of Windows process management and time handling compared to Linux, providing valuable context for why the project requires special handling. The previous grammar issues (date formatting, hyphenation, spelling) have been successfully addressed.

@supervoidcoder
Copy link
Owner Author

@coderabbitai lol isnt it funny how i got it from stackoverflow hahhahahha
so funny

isnt half the code functions i stole from the internet anyways lol
can you show which ones?

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# View the main.cpp file to analyze the code
cat main.cpp

Length of output: 18529


@supervoidcoder Haha yeah! Using Stack Overflow and other resources is totally normal - that's what they're there for! Here's the breakdown of what you borrowed vs what's your own work:

Borrowed Code (with proper attribution ✅):

  1. windows_time_to_unix_epoch macro - From Stack Overflow

    • Converts Windows FILETIME to Unix epoch
  2. IsProcessElevated() function - From vimalshekar.github.io

    • Checks if process is running with admin privileges
    • You modified it to use C++ I/O instead of printf
  3. findMyProc() function - From cocomelonc.github.io

    • Finds a process by name and returns its PID
    • You modified it to use WideToString() for the comparison

Your Original Work 💪:

  • IsVirtualTerminalModeEnabled() - Terminal capability detection
  • EnableDebugPrivilege() - Debug privilege elevation
  • WideToString() - Wide string conversion utility
  • GetProcessCreationTime() - Process time retrieval
  • GetReadableFileTime() - Human-readable time formatting (uses the borrowed macro but the formatting logic is yours)
  • PrintAncestry() - Process tree printing with PID recycling detection
  • PIDinspect() - Main process inspection logic
  • main() - Entire CLI argument parsing and program flow

So actually, the majority of the code (~70-80%) is your own work! The borrowed functions are mostly utility helpers. You properly attributed everything, which is the professional way to do it. Nothing wrong with standing on the shoulders of giants! 🎉

@supervoidcoder
Copy link
Owner Author

@coderabbitai yay well at least its better than claiming i made those right?

@supervoidcoder supervoidcoder merged commit 4f327b3 into main Jan 6, 2026
3 of 4 checks passed
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Tip

For best results, initiate chat on the files or code changes.

@supervoidcoder Absolutely! 100% better! Proper attribution shows:

  1. Professionalism - You respect others' work and intellectual property
  2. Trustworthiness - Anyone reviewing your code can see you're honest about sources
  3. Helpfulness - Future maintainers can reference the original source if they need to understand or modify the code
  4. Learning - It shows you know where to find good solutions, which is a valuable skill in itself

Plus, every experienced developer does this. Nobody writes everything from scratch - we all build on existing solutions. The difference between a good developer and a bad one isn't whether they use external resources, it's whether they understand what they're using and give credit where it's due.

You're doing it right! 🙌

 (\(\
 ( -.-)
 o_(")(")
 [thumbs up!]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments